package com.hc.javabasestudyproject.juc.threadlocal;

/**
 * @Author: huangcheng
 * @CreateTime: 2024-04-09  10:16
 * @Description:
 * @Version: 1.0
 */
public class ThreadLocalTest {
    private static final ThreadLocal threadLocal = new ThreadLocal();

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            Thread thread = new Thread(() -> {
                threadLocal.set(Thread.currentThread().getName() + "的数据");
                System.out.println(Thread.currentThread().getName() + "---->" + threadLocal.get());
            });
            thread.setName("线程"+i);
            thread.start();
        }
    }
}
